component{
	//entityObj实体对象，字符串变量
	this.entityObj  = '';

	function init(fw)
	{
		variables.fw = fw;
	}

	//通过evaluate获取到真正的实体对象内容
	public any function getEntityObj(){
		return 	evaluate("variables." & this.entityObj);
	}

	//列表
	public void function list(any rc,string moduleSqlWhere){
		/*初始变量rows与pager的设置*/
		if(!structKeyExists(rc, "rows") || (!isNumeric(rc.rows) || rc.rows <= 0 || round(rc.rows) != rc.rows))
		{
			rc.rows = request.rows;
		}

		if(!structKeyExists(rc, "page") || (!isNumeric(rc.page) || rc.page <= 0 || round(rc.page) != rc.page))
		{
			rc.page = 1;
		}

		/*查询条件*/
		rc.sqlWhere = " 1 = 1 ";

		if( structKeyExists(rc, "subject") && len(trim(rc.subject)) >0 ){
			rc.sqlWhere = rc.sqlWhere & " and subject like '%" & subject & "%' " ;
		}

		if( structKeyExists(rc, "created_ge") && len(trim(rc.created_ge)) >0 ){
			rc.sqlWhere = rc.sqlWhere & " and created >= '" & rc.created_ge & "'" ;
		}

		if( structKeyExists(rc, "created_le") && len(trim(rc.created_le)) >0 ){
			rc.sqlWhere = rc.sqlWhere & " and created <= '" & rc.created_le & "'" ;
		}

		if( structKeyExists(arguments, "moduleSqlWhere") && len(trim(arguments.moduleSqlWhere))>0 ){
			rc.sqlWhere = rc.sqlWhere & moduleSqlWhere;
		}

		/*排序条件*/
		if( structKeyExists(rc, "sort")  && len(trim(rc.sort))>0 )
		{
			rc.sqlSort = " order by " & rc.sort & " ";
		}else{
			rc.sqlSort = "  order by id ";
		}

		if( structKeyExists(rc, "order")  && len(trim(rc.order))>0 )
		{
			rc.sqlSort = rc.sqlSort  &  rc.order;
		}else{
			rc.sqlSort = rc.sqlSort & " desc ";

		}

		/*分页操作service的调用*/
		rc.json = getEntityObj().list(rc);

		/*返回json数据*/
		variables.fw.renderData('json', rc.json);
	}

	//新增
	public void function save(rc){
		rc.data = getEntityObj().save(rc);
		variables.fw.renderData('json', true);
	}

	//修改
	public void function update(rc){
		rc.data = getEntityObj().update(rc);
		variables.fw.renderData('json', true);
	}

	//删除
	public void function delete(rc){
		 getEntityObj().delete(rc.id);
		 variables.fw.renderData('json',true);
	}

	//通过ID获取详细内容
	public void function get(rc){
		rc.json = getEntityObj().get(rc.id);
		variables.fw.renderData('json', rc.json);
	}

	//通过IDs获取多个详细内容
	public void function gets(rc){
		rc.json = getEntityObj().gets(rc);
		variables.fw.renderData('json', rc.json);
	}

	//获取所有
	public void function getall(rc){
		rc.json = getEntityObj().getall(rc);
		variables.fw.renderData('json', rc.json);
	}

	//发布
	public void function publish(rc){
		rc.data = getEntityObj().publish(rc.id);
		variables.fw.renderData('json', true);
	}

	public void function publishbat(rc){
		rc.data = getEntityObj().publishbat(rc);
		variables.fw.renderData('json', true);
	}

	//推荐
	public void function commend(rc){
		rc.data = getEntityObj().commend(rc.id);
		variables.fw.renderData('json', true);
	}

	public void function commendbat(rc){
		rc.data = getEntityObj().commendbat(rc);
		variables.fw.renderData('json', true);
	}

	//评论
	public void function comment(rc){
		rc.data = getEntityObj().comment(rc.id);
		variables.fw.renderData('json', true);
	}

	public void function commentbat(rc){
		rc.data = getEntityObj().commentbat(rc);
		variables.fw.renderData('json', true);
	}

	//滚动
	public void function scroll(rc){
		rc.data = getEntityObj().scroll(rc.id);
		variables.fw.renderData('json', true);
	}

	public void function scrollbat(rc){
		rc.data = getEntityObj().scrollbat(rc);
		variables.fw.renderData('json', true);
	}

	//分类
	public void function category(){
		rc.json = getEntityObj().category(rc);
		variables.fw.renderData('json', rc.json);
	}

	//获取树形
	public void function getTree(rc){
		rc.json = getEntityObj().getTree(rc);
		variables.fw.renderData('json', rc.json);
	}

	//获取分类
	public void function getCategoryType(rc){
		rc.json = getEntityObj().getCategoryType();
		variables.fw.renderData('json', rc.json);
	}

	//授权
	public void function savegrant(rc){
		rc.data = getEntityObj().savegrant(rc);
		variables.fw.renderData('json', true);
	}


	public void function test(rc){
		rc.data = getEntityObj().test(rc);
//		variables.fw.renderData('json', true);
	}

}